(function(n) {
    Ares = n.Ares || {};
    Ares.DcmImageCache = function(n) {
        function e(n) {
            i = n.width;
            r = n.height;
            t = []
        }

        function o(n, e, o) {
            var h = "",
                s;
            h = "&rows=" + parseInt(r) + "&columns=" + parseInt(i);
            s = new Image;
            s.src = u + "requestType=WADO&studyUID=" + n.studyUID + "&seriesUID=" + n.seriesUID + "&objectUID=" + n.instanceUID + "&tenantId=" + n.tenantId + "&officeId=" + n.officeId + "&appointmentId=" + n.appointmentId + "&imageQuality=" + f + h;
            s.ondragstart = function() {
                return !1
            };
            s.onload = function() {
                t[e][o] = {};
                t[e][o].w = s.width;
                t[e][o].h = s.height;
                t[e][o].img = s;
                t[e][o].i = o
            };
            s.onerror = function() {}
        }
        var u = "/Dcm/FetchImage?",
            f = 30,
            i, r, t;
        e(n);
        this.getSeriesCache = function(n, i) {
            if (t[i] == null || !(t[i].length > 0)) {
                t[i] = [];
                for (var r = 0; r < n.length; r++) o(n[r], i, r)
            }
        };
        this.getCachedImg = function(n, i) {
            return t[n][i] != null ? t[n][i] : null
        }
    }
})(window),
function(n) {
    Ares = n.Ares || {};
    Ares.dcmControl = function(n) {
        function pt(n) {
            var f, o, h;
            a = !0;
            $("#dcm-image-tool td").kendoTooltip({
                autoHide: !0
            });
            f = {};
            f.jpegMode = !0;
            r.append('<canvas style="position:absolute;"><\/canvas>');
            f.canvas = r.find("canvas");
            r.append('<img style="position:absolute;"><\/img>');
            f.jpegShow = r.find("img");
            r.append('<div style="position:absolute;"><\/div>');
            f.cacheItem = r.find("div");
            r.append('<span id="info_lt" style="color:#fff;position:absolute;left:5px;top:5px;"><\/span>');
            r.append('<span id="info_rb" style="width:180px;color:#fff;position:absolute;" align="right"><\/span>');
            f.infoLT = $(r.find("span")[0]);
            f.infoRB = $(r.find("span")[1]);
            yt = parseInt(n.width);
            f.width = parseInt(n.width);
            ct = parseInt(n.height);
            f.height = parseInt(n.height);
            r.append('<div style="position:absolute;"><\/div>');
            f.scalePlateX = $(r.find("div")[1]);
            r.append('<div style="position:absolute;"><\/div>');
            f.scalePlateY = $(r.find("div")[2]);
            r.append('<div style="position:absolute;background:#00ff00;height:2px;left:0px;top:' + (ct - 3) + 'px;"><\/div>');
            f.progressbar = $(r.find("div")[3]);
            r.append('<div style="position:absolute;left:0px;top:0px;"><\/div>');
            f.action = $(r.find("div")[4]);
            f.ml = 0;
            f.mt = 0;
            o = "click";
            w = n.resizeButton;
            w.bind(o, function() {
                event.preventDefault();
                e = 1;
                p(e)
            });
            b = n.moveButton;
            b.bind(o, function() {
                event.preventDefault();
                e = 2;
                p(e)
            });
            k = n.winlevelButton;
            k.bind(o, function() {
                event.preventDefault();
                e = 3;
                p(e)
            });
            d = n.resetButton;
            d.bind(o, function() {
                event.preventDefault();
                d.children().attr("src", "/app-resource/images/dcm/reset_e.png");
                setTimeout(function() {
                    d.children().attr("src", "/app-resource/images/dcm/reset.png")
                }, 500);
                i.resetImage()
            });
            g = n.upButton;
            g.bind(o, function() {
                event.preventDefault();
                s > 0 && (g.children().attr("src", "/app-resource/images/dcm/up_e.png"), setTimeout(function() {
                    g.children().attr("src", "/app-resource/images/dcm/up.png")
                }, 500), s--, ft())
            });
            nt = n.downButton;
            nt.bind(o, function() {
                event.preventDefault();
                s < t[u].length - 1 && (nt.children().attr("src", "/app-resource/images/dcm/down_e.png"), setTimeout(function() {
                    nt.children().attr("src", "/app-resource/images/dcm/down.png")
                }, 500), s++, ft())
            });
            ot = n.clockwiseButton;
            ot.bind(o, function() {
                event.preventDefault();
                i.clockWise()
            });
            st = n.anticlockwiseButton;
            st.bind(o, function() {
                event.preventDefault();
                i.antiClockWise()
            });
            tt = n.changeModeButton;
            tt.bind(o, function() {
                event.preventDefault();
                a ? (tt.children().attr("src", "/app-resource/images/dcm/pixel.png"), a = !1) : (tt.children().attr("src", "/app-resource/images/dcm/jpeg.png"), a = !0);
                i.changeMode(a);
                i.getImage(!0)
            });
            ht = n.infoButton;
            ht.bind(o, function() {
                event.preventDefault();
                $("#dicomInfoModal").modal("show");
                $("#dicomInfoModal .modal-dialog").css("margin-top", "20px");
                $("#dicomInfoModal .modal-title").text("Dicom 信息");
                i.refreshMeta()
            });
            it = n.downloadJpgButton;
            it.bind(o, function() {
                e = 4;
                p(e);
                Ares.download(ii())
            });
            rt = n.downloadDcomButton;
            rt.bind(o, function() {
                e = 5;
                p(e);
                $.ajax({
                    type: "POST",
                    url: ri(),
                    dataType: "json",
                    success: function(n) {
                        n && n.SignUrl ? Ares.download(ui(n.SignUrl)) : alert("下载失败，请重试！")
                    }
                })
            });
            r.bind("mousedown", function(n) {
                gt(n)
            });
            $("body").bind("mouseup", function(n) {
                ti(n)
            });
            $("body").bind("mousemove", function(n) {
                ni(n)
            });
            i = new Ares.dcmObject(f);
            r.mousewheel(function(n, r) {
                var f, e;
                n.preventDefault();
                y = !0;
                f = s - r;
                f >= 0 && f < t[u].length && (s = f, e = ut.getCachedImg(u, s), i.showCache(e), ft())
            });
            h = {};
            h.width = n.width;
            h.height = n.height;
            ut = new Ares.DcmImageCache(h);
            wt(n.image)
        }

        function wt(n) {
            $.ajax({
                type: "POST",
                url: "/Dcm/QueryImage",
                data: {
                    appointmentId: n.appointmentId
                },
                dataType: "json",
                success: function(i) {
                    var u, s, e, r, o, f;
                    if (i.dicom != null && i.dicom.length > 0) {
                        for (u = 0, t[u] = [], s = i.dicom[0].seriesUID, t[u].push(i.dicom[0]), r = 1; r < i.dicom.length; r++) i.dicom[r].seriesUID != s ? (u++, t[u] = [], s = i.dicom[r].seriesUID, t[u].push(i.dicom[r])) : t[u].push(i.dicom[r]);
                        for (kt(), y = !1, e = 0, r = 0; r < t.length; r++)
                            for (o = 0; o < t[r].length; o++)
                                if (f = t[r][o], n.thumbnailUrl.indexOf("studyUID=" + f.studyUID) > 0 && n.thumbnailUrl.indexOf("seriesUID=" + f.seriesUID) > 0 || n.mediumSizeImageUrl.indexOf("studyUID=" + f.studyUID) > 0 && n.mediumSizeImageUrl.indexOf("seriesUID=" + f.seriesUID) > 0 || n.studyUID == f.studyUID && n.seriesUID == f.seriesUID) {
                                    e = r;
                                    break
                                }
                        e == 0 ? lt(0) : dcmControl.switchSeries(e)
                    } else alert("无法获取图像信息")
                }
            })
        }

        function lt(n) {
            u = n;
            vt();
            s = 0;
            i.changeImage(t[u][0]);
            i.getImage(!0);
            i.showImageIndex(0, t[u].length);
            ut.getSeriesCache(t[u], u)
        }

        function at(n) {
            return n == "F" ? "女" : "男"
        }

        function bt(n) {
            var r, t, i, u, f;
            if (n == null || n == "") return "";
            for (r = n.split("^"), t = [], i = 0; i < r.length; ++i) u = r[i].replace("=", ""), f = u.replace(" ", ""), f.length > 0 && t.push(u);
            return t.length > 0 ? t[t.length - 1] : ""
        }

        function kt() {
            var i, n;
            for (f.append("<table>"), f.append('<tr><td style="width:100px;color:#ddd;text-align:right;">姓名：<\/td><td style="color:#fff;font:bolder;">' + o(bt(t[0][0].patName)) + "<\/td><\/tr>"), f.append('<tr><td style="width:100px;color:#ddd;text-align:right;">性别：<\/td><td style="color:#fff;font:bolder;" >' + o(at(t[0][0].sex)) + "<\/td><\/tr>"), f.append('<tr><td style="width:100px;color:#ddd;text-align:right;">检查类型：<\/td><td style="color:#fff;font:bolder;" >' + o(t[0][0].modality) + "<\/td><\/tr>"), f.append('<tr><td style="width:100px;color:#ddd;text-align:right;">检查时间：<\/td><td style="color:#fff;font:bolder;" >' + o(moment(t[0][0].seriesDateTime).format("YYYY-MM-DD")) + "<\/td><\/tr>"), f.append('<tr><td style="width:100px;color:#ddd;text-align:right;">序列图像数：<\/td><td style="color:#fff;font:bolder;" >' + o(t[0][0].length) + "<\/td><\/tr>"), f.append('<tr><td style="width:100px;color:#ddd;text-align:right;">序列描述：<\/td><td style="color:#fff;font:bolder;" >' + o(t[0][0].seriesDesc) + "<\/td><\/tr>"), f.append("<\/table>"), f.append('<div style="margin-top:10px;margin-bottom:10px;border:1px solid #efefef;"><\/div>'), f.append('<div id="thumblist" style="width:200px;margin-top:15px; overflow-y:scroll;"><\/div>'), v = f.find("#thumblist"), u = 0, i = 0; i < t.length; i++) n = t[i][0], i == 0 ? v.append("<img seriesIndex=" + i + ' onclick="dcmControl.switchSeries(' + i + ')" style="margin:0px 10px;border:2px solid #46aaf6;width:170px;height:170px;" src="/Dcm/FetchImage?requestType=WADO&studyUID=' + n.studyUID + "&seriesUID=" + n.seriesUID + "&objectUID=" + n.instanceUID + "&tenantId=" + n.tenantId + "&officeId=" + n.officeId + "&appointmentId=" + n.appointmentId + "&rows=170&columns=170&imageQuality=50&d=" + Math.random() + '" />') : v.append("<img seriesIndex=" + i + ' onclick="dcmControl.switchSeries(' + i + ')" style="margin:0px 10px;border:2px solid #808080;width:170px;height:170px;" src="/Dcm/FetchImage?requestType=WADO&studyUID=' + n.studyUID + "&seriesUID=" + n.seriesUID + "&objectUID=" + n.instanceUID + "&tenantId=" + n.tenantId + "&officeId=" + n.officeId + "&appointmentId=" + n.appointmentId + "&rows=170&columns=170&imageQuality=50&d=" + Math.random() + '" />')
        }

        function dt() {
            $(f.find("h4")[0]).html("姓名：" + o(t[u][0].patName));
            $(f.find("h4")[1]).html("性别：" + o(at(t[u][0].sex)));
            $(f.find("h4")[2]).html("检查类型：" + o(t[u][0].modality));
            $(f.find("h4")[3]).html("序列时间：" + o(moment(t[0][0].seriesDateTime).format("YYYY-MM-DD")));
            $(f.find("h4")[4]).html("序列图像数：" + o(t[u].length));
            $(f.find("h4")[5]).html("序列描述：" + o(t[u][0].seriesDesc))
        }

        function o(n) {
            return n == null || n == "null" ? "" : n
        }

        function vt() {}

        function ft() {
            i.showImageIndex(s, t[u].length);
            y && clearTimeout(et);
            y = !0;
            et = setTimeout(function() {
                i.changeImage(t[u][s]);
                i.getImage(!1);
                y = !1
            }, 500)
        }

        function gt(n) {
            var t = n.pageX,
                i = n.pageY;
            h = !0;
            l = t;
            c = i;
            return
        }

        function ni(n) {
            var u = n.pageX,
                r = n.pageY,
                o, f, t;
            h && e == 1 ? (t = r - c, l = u, c = r, o = 1 - t / 500, i.zoomInCanvas(o)) : h && e == 2 ? (f = u - l, t = r - c, l = u, c = r, i.moveImage(f, t)) : h && e == 3 && (f = u - l, t = r - c, i.changeWinLevel(f, t), l = u, c = r)
        }

        function ti() {
            h && e == 1 ? i.zoomInServer() : h && e == 3 && a && i.getImage(!1);
            h = !1
        }

        function p(n) {
            w.children().attr("src", "/app-resource/images/dcm/resize.png");
            b.children().attr("src", "/app-resource/images/dcm/move.png");
            k.children().attr("src", "/app-resource/images/dcm/winlevel.png");
            it.children().attr("src", "/app-resource/images/dcm/download.png");
            rt.children().attr("src", "/app-resource/images/dcm/dcm-download.png");
            n == 1 ? w.children().attr("src", "/app-resource/images/dcm/resize_e.png") : n == 2 ? b.children().attr("src", "/app-resource/images/dcm/move_e.png") : n == 3 ? k.children().attr("src", "/app-resource/images/dcm/winlevel_e.png") : n == 4 ? it.children().attr("src", "/app-resource/images/dcm/download-blue.png") : n == 5 && rt.children().attr("src", "/app-resource/images/dcm/dcm-download-blue.png")
        }

        function ii() {
            return i.getImageUrl()
        }

        function ri() {
            return i.getDcomSignUrl()
        }

        function ui(n) {
            return i.getFetchDcomUrl(n)
        }
        var r = n.viewer,
            f = n.leftBar,
            v, u = 0,
            s = 0,
            i, t = [],
            et, y, e = -1,
            w, b, k, d, g, nt, tt, ot, st, it, rt, ht, h, l, c, yt, ct, a = !0,
            ut;
        pt(n);
        this.switchSeries = function(n) {
            u != n && (u = n, dt(), vt(), v.children().css("border-color", "#808080"), $(v.children()[u]).css("border-color", "#46aaf6"), lt(n))
        }
    }
}(window),
function(n) {
    Ares = n.Ares || {};
    Ares.dcmObject = function(t) {
        function ai(n) {
            p = n.canvas;
            w = n.jpegShow;
            k = n.jpegMode;
            tt = p[0].getContext("2d");
            tt.fillStyle = "#000000";
            k ? (w.show(), p.hide(), o = w, w.attr("src", "")) : (p.show(), w.hide(), o = p);
            wt = n.action;
            ti = n.infoLT;
            lt = n.infoRB;
            c = n.width;
            a = n.height;
            l = n.cacheItem;
            l.hide();
            nt = n.progressbar;
            lt.css("left", c - 190);
            lt.css("top", a - 40);
            bt = n.ml;
            kt = n.mt;
            b = n.scalePlateX;
            d = n.scalePlateY;
            wt.css("width", c);
            wt.css("height", a);
            s.x = bt + c / 2;
            s.y = kt + a / 2;
            rt.x = s.x;
            rt.y = s.y;
            i.w = parseInt(c);
            i.h = parseInt(a);
            u.w = i.w;
            u.h = i.h;
            v = 0;
            at.C = 2e3 / (a - kt);
            at.W = 2e3 / (c - bt);
            it = 0
        }

        function vt(n, t) {
            t == null ? (t = {}, n ? (t.w = c, t.h = a) : (t.w = i.w, t.h = i.h)) : (t.w == null && (t.w = i.w), t.h == null && (t.h = i.h));
            n ? (v = 0, o.css("transform", "rotate(0deg)"), l.css("transform", "rotate(" + v + "deg)")) : (t.WinW != null || isNaN(r.WinW) || (t.WinW = r.WinW), t.WinC != null || isNaN(r.WinC) || (t.WinC = r.WinC));
            dt = !0;
            b.empty();
            d.empty();
            k ? yi(n, t) : vi(n, t)
        }

        function vi(t, r) {
            var u, o = null,
                f, s;
            u = n.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
            f = "";
            f += "&rows=" + parseInt(r.h);
            f += "&columns=" + parseInt(r.w);
            u.open("GET", yt + "requestType=GSPS&studyUID=" + ft + "&tenantId=" + ct + "&officeId=" + ht + "&appointmentId=" + ut + "&seriesUID=" + et + "&objectUID=" + ot + f + "&ts=" + (new Date).getTime());
            u.responseType = "arraybuffer";
            u.timeout = ni;
            it++;
            s = it;
            u.onload = function() {
                if (this.status == 200 || this.status == 0) {
                    if (s < it) return;
                    nt.css("width", c);
                    e = {};
                    e.width = u.getResponseHeader("Width");
                    e.height = u.getResponseHeader("Height");
                    i.w = parseInt(e.width);
                    i.h = parseInt(e.height);
                    e.BitType = this.response.byteLength / parseInt(this.getResponseHeader("Width")) / parseInt(this.getResponseHeader("Height"));
                    e.BitType == 1 || e.BitType == 3 ? g = new Uint8Array(this.response) : e.BitType == 2 && (g = new Int16Array(this.response));
                    e.Inverse = u.getResponseHeader("Inverse");
                    e.Defaultcenter = u.getResponseHeader("Defaultcenter");
                    e.Defaultwindow = u.getResponseHeader("Defaultwindow");
                    gt(t);
                    nt.css("width", 0)
                }
            };
            u.onprogress = function(n) {
                var t = this.getResponseHeader("Content-Length");
                t != null && (o = parseInt(t));
                o != null && nt.css("width", c * (n.loaded / o))
            };
            nt.css("width", 0);
            u.send()
        }

        function yi(t, r) {
            var u, o, f, s;
            u = n.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
            f = "";
            f += "&rows=" + parseInt(r.h);
            f += "&columns=" + parseInt(r.w);
            r.WinW != null && r.WinC != "" && (f = f + "&windowWidth=" + r.WinW + "&windowCenter=" + r.WinC);
            f = r.quality != null ? f + "&imageQuality=" + r.quality : f + "&imageQuality=" + li;
            u.open("GET", yt + "requestType=WADO&studyUID=" + ft + "&seriesUID=" + et + "&objectUID=" + ot + "&tenantId=" + ct + "&officeId=" + ht + "&appointmentId=" + ut + f);
            u.withCredentials = !0;
            u.responseType = "arraybuffer";
            u.timeout = ni;
            it++;
            s = it;
            u.onload = function() {
                var n;
                if (this.status == 200 || this.status == 0) {
                    if (s < it) return;
                    nt.css("width", c);
                    e = {};
                    e.width = u.getResponseHeader("Width");
                    e.height = u.getResponseHeader("Height");
                    i.w = parseInt(e.width);
                    i.h = parseInt(e.height);
                    e.Inverse = u.getResponseHeader("Inverse");
                    e.Defaultcenter = u.getResponseHeader("Defaultcenter");
                    e.Defaultwindow = u.getResponseHeader("Defaultwindow");
                    var r = "",
                        o = this.mozResponseArrayBuffer || this.response,
                        f = new Uint8Array(o);
                    for (n = 0; n < f.byteLength; n++) r += String.fromCharCode(f[n]);
                    gt(t, r)
                }
            };
            r.quality == null && (u.onprogress = function(n) {
                var t = this.getResponseHeader("Content-Length");
                t != null && (o = parseInt(t));
                o != null && nt.css("width", c * (n.loaded / o))
            });
            nt.css("width", 0);
            u.send()
        }

        function gt(n, t) {
            n && (s.x = rt.x, s.y = rt.y, u.w = i.w, u.h = i.h);
            n && ei();
            o.attr("width", i.w);
            o.attr("height", i.h);
            n ? (o.css("left", s.x - i.w / 2), o.css("top", s.y - i.h / 2), o.css("width", i.w), o.css("height", i.h)) : (o.css("left", s.x - u.w / 2), o.css("top", s.y - u.h / 2));
            l.hide();
            o.show();
            pi();
            ri();
            ui();
            k ? wi(t) : fi();
            dt = !1
        }

        function pi() {
            var t, n;
            if (y = {}, t = f.PixelSpacing, y.X = f.pixelSpacingX, y.Y = f.pixelSpacingY, f.columns == "") {
                y = {};
                return
            }
            n = f.columns / parseFloat(i.w);
            y.X = y.X * n;
            y.Y = y.Y * n
        }

        function ri() {
            var t, n, r;
            if ((b.empty(), y.X != null) && f.modality != "IO" && (t = 10, baseL = 10 / (y.X * (i.w / u.w)), baseL < 5 ? (t = 80, baseL = baseL * 8) : baseL < 10 ? (t = 40, baseL = baseL * 4) : baseL < 20 ? (t = 20, baseL = baseL * 2) : baseL > 80 && (t = 5, baseL = baseL / 2), n = Math.round(c * .4 / baseL), n > 10 && (n = 10), !(baseL < 4)))
                for (b.css("left", (c - baseL * n) / 2), b.css("top", a - 16), b.css("width", baseL * n), b.append('<div style="border-top: 1px solid #ffa500;position:absolute;top:10px;left:0px;height:0px;width:' + baseL * n + 'px;"><\/div>'), r = 0; r <= n; r++) b.append('<div style="border-left: 1px solid #ffa500;position:absolute;top:0px;left:' + r * baseL + 'px;height:10px;width:0px;"><\/div>'), r == n && b.append('<span style="font-size:10px;color:#ffa500;position:absolute;top:0px;left:' + (r * baseL + 15) + 'px">' + t + "mm<\/span>")
        }

        function ui() {
            var n, r, t;
            if ((d.empty(), y.X != null) && f.modality != "IO" && (baseL = 10 / (y.X * (i.w / u.w)), baseL < 5 ? baseL = baseL * 8 : baseL < 10 ? baseL = baseL * 4 : baseL < 20 ? baseL = baseL * 2 : baseL > 80 && (baseL = baseL / 2), n = Math.round(a * .4 / baseL), n > 10 && (n = 10), !(baseL < 4)))
                for (r = c - 23, d.css("left", c - 23), d.css("top", (a - baseL * n) / 2), d.css("height", a - baseL * n), d.append('<div style="border-left: 1px solid #ffa500;position:absolute;top:0px;left:10px;height:' + baseL * n + 'px;width:0px;"><\/div>'), t = 0; t <= n; t++) d.append('<div style="border-top: 1px solid #ffa500;position:absolute;top:' + t * baseL + 'px;left:0px;height:0px;width:10px;"><\/div>')
        }

        function fi() {
            e.BitType != 3 ? bi() : e.BitType == 3 && ki()
        }

        function wi(n) {
            u.w = i.w;
            u.h = i.h;
            w.attr("src", "data:image/jpeg;base64," + btoa(n))
        }

        function bi() {
            var t = tt.createImageData(i.w, i.h),
                f, r, n, u;
            for (f = e.Inverse == null || e.Inverse == "False" ? gi : nr, r = 0, n = 0; r < g.length; r++) u = f(di(g[r])), t.data[n] = u, t.data[n + 1] = u, t.data[n + 2] = u, t.data[n + 3] = 255, n = n + 4;
            tt.putImageData(t, 0, 0)
        }

        function ki() {
            for (var t = tt.createImageData(i.w, i.h), r = 0, n = 0; r < g.length;) t.data[n] = g[r++], t.data[n + 1] = g[r++], t.data[n + 2] = g[r++], t.data[n + 3] = 255, n = n + 4;
            tt.putImageData(t, 0, 0)
        }

        function di(n) {
            return n <= st ? n = st : n >= pt && (n = pt), n
        }

        function gi(n) {
            return Math.floor((n - st) * (255 / r.WinW))
        }

        function nr(n) {
            return Math.abs(255 - Math.floor((n - st) * (255 / r.WinW)))
        }

        function ei() {
            var strW = f.windowWidth,
                strC = f.windowCenter,
                wa, ca;
            strW == null || strW == "" || strC == null || strC == "" ? (r.WinW = parseInt(e.Defaultwindow), r.WinC = parseInt(e.Defaultcenter)) : (wa = eval("(" + strW + ")"), ca = eval("(" + strC + ")"), r.WinW = wa, r.WinC = ca);
            oi(r.WinW, r.WinC);
            return
        }

        function oi(n, t) {
            n != null && t != null && ((r.WinW = parseInt(n, 10), r.WinC = parseInt(t, 10), isNaN(r.WinW) || isNaN(r.WinC)) || (r.WinW <= 1 && (r.WinW = 1), st = r.WinC - r.WinW / 2, pt = r.WinC + r.WinW / 2, lt.html("W:" + r.WinW + "<br />C:" + r.WinC)))
        }
        var yt = "/Dcm/FetchImage?",
            si = "/Dcm/GetDcomSignUrl?",
            hi = "/Dcm/FetchDcom?",
            ci = 10,
            li = 95,
            ni = 8e3,
            ht, ct, ut, ft, et, ot, c, a, st, pt, k, f, e, g, rt = {},
            s = {},
            i = {},
            u = {},
            r = {},
            p, tt, w, v, o, it = 0,
            wt, ti, lt, bt, kt, at = {},
            ii = .5,
            dt, l, b, d, y, nt, h = $(".table-striped");
        ai(t);
        this.changeMode = function(n) {
            k = n;
            k ? (tt.fillRect(0, 0, parseInt(p.attr("width")), parseInt(p.attr("heigt"))), w.show(), p.hide(), o = w) : (w.attr("src", ""), p.show(), w.hide(), o = p)
        };
        this.changeImage = function(n) {
            ft = n.studyUID;
            et = n.seriesUID;
            ot = n.instanceUID;
            ut = n.appointmentId;
            ht = n.officeId;
            ct = n.tenantId;
            f = n
        };
        this.getImage = function(n, t) {
            vt(n, t)
        };
        this.getImageUrl = function() {
            var n = "";
            return r.WinW && r.WinC && !isNaN(r.WinW) && !isNaN(r.WinC) && (n = n + "&windowWidth=" + r.WinW + "&windowCenter=" + r.WinC), yt + "requestType=DOWNLOAD&studyUID=" + ft + "&seriesUID=" + et + "&objectUID=" + ot + "&tenantId=" + ct + "&officeId=" + ht + "&appointmentId=" + ut + n
        };
        this.getDcomSignUrl = function() {
            return si + "studyUID=" + ft + "&seriesUID=" + et + "&objectUID=" + ot
        };
        this.getFetchDcomUrl = function(n) {
            return hi + "signUrlBase64=" + n + "&appointmentId=" + ut
        };
        this.showCache = function(n) {
            n != null && (l.css("width", u.w), l.css("height", u.h), l.css("left", s.x - u.w / 2), l.css("top", s.y - u.h / 2), l.show(), l.empty(), l.append(n.img), l.children().css("width", "100%"), l.children().css("height", "100%"), o.hide())
        };
        this.zoomInCanvas = function(n) {
            u.w * n > c * 2 || u.h * n > a * 2 || u.h * n < a / 2 || (b.empty(), d.empty(), u.w = u.w * n, u.h = u.h * n, o.css("width", u.w), o.css("height", u.h), o.css("left", s.x - u.w / 2), o.css("top", s.y - u.h / 2))
        };
        this.zoomInServer = function() {
            if (k && f.modality != "IO") {
                var n = {};
                n.w = u.w;
                n.h = u.h;
                vt(!1, n)
            } else ri(), ui()
        };
        this.moveImage = function(n, t) {
            s.x = s.x + n;
            s.y = s.y + t;
            o.css("left", s.x - u.w / 2);
            o.css("top", s.y - u.h / 2)
        };
        this.resetImage = function() {
            ei();
            s.x = rt.x;
            s.y = rt.y;
            k ? (i.w = parseInt(c), i.h = parseInt(a), u.w = i.w, u.h = i.h, vt(!0)) : (u.w = i.w, u.h = i.h, gt(!0));
            v != 0 && (v = 0, o.css("transform", "rotate(0deg)"), l.css("transform", "rotate(" + v + "deg)"))
        };
        this.clockWise = function() {
            v = v + 90;
            o.css("transform", "rotate(" + v + "deg)");
            l.css("transform", "rotate(" + v + "deg)")
        };
        this.antiClockWise = function() {
            v = v - 90;
            o.css("transform", "rotate(" + v + "deg)");
            l.css("transform", "rotate(" + v + "deg)")
        };
        this.changeWinLevel = function(n, t) {
            if (!isNaN(r.WinW))
                if (oi(r.WinW + n * at.W * ii, r.WinC - t * at.C * ii), k) {
                    if (!dt) {
                        var i = {};
                        i.WinW = r.WinW;
                        i.WinC = r.WinC;
                        i.quality = ci;
                        vt(!1, i)
                    }
                } else fi()
        };
        this.showImageIndex = function(n, t) {
            ti.html("序列图像编号:" + (n + 1) + "<br />序列图像总数:" + t + "<\/br>")
        };
        this.refreshMeta = function() {
            h.empty();
            h.append("<tr><td>StudyUID<\/td><td>" + f.studyUID + "<\/td><\/tr>");
            h.append("<tr><td>SeriesUID<\/td><td>" + f.seriesUID + "<\/td><\/tr>");
            h.append("<tr><td>InstanceUID<\/td><td>" + f.instanceUID + "<\/td><\/tr>");
            h.append("<tr><td>Modality<\/td><td>" + f.modality + "<\/td><\/tr>");
            h.append("<tr><td>SopClassUID<\/td><td>" + f.sopClassUID + "<\/td><\/tr>");
            h.append("<tr><td>SpecificCharacterSet<\/td><td>" + f.specificCharacterSet + "<\/td><\/tr>");
            h.append("<tr><td>Columns<\/td><td>" + f.columns + "<\/td><\/tr>");
            h.append("<tr><td>Rows<\/td><td>" + f.rows + "<\/td><\/tr>");
            h.append("<tr><td>DefaultWindowCenter<\/td><td>" + f.windowCenter + "<\/td><\/tr>");
            h.append("<tr><td>DefaultWindowWidth<\/td><td>" + f.windowWidth + "<\/td><\/tr>");
            h.append("<tr><td>ImageOrientation<\/td><td>" + f.imageOrientation + "<\/td><\/tr>");
            h.append("<tr><td>PatientOrientation<\/td><td>" + f.patientOrientation + "<\/td><\/tr>");
            h.append("<tr><td>PhotoMetric<\/td><td>" + f.photoMetric + "<\/td><\/tr>");
            h.append("<tr><td>PixelRepresentation<\/td><td>" + f.pixelRepresentation + "<\/td><\/tr>");
            h.append("<tr><td>PixelSpacingX<\/td><td>" + f.pixelSpacingX + "<\/td><\/tr>");
            h.append("<tr><td>PixelSpacingY<\/td><td>" + f.pixelSpacingY + "<\/td><\/tr>");
            h.append("<tr><td>RescaleIntercept<\/td><td>" + f.rescaleIntercept + "<\/td><\/tr>");
            h.append("<tr><td>RescaleSlope<\/td><td>" + f.rescaleSlope + "<\/td><\/tr>");
            h.append("<tr><td>NumberOfFrames<\/td><td>" + f.numberOfFrames + "<\/td><\/tr>")
        }
    }
}(window),
function(n) {
    Ares = n.Ares || {};
    Ares.normalImgControl = function(n) {
        function it(n) {
            var i, t;
            for (r.css("overflow", "hidden"), i = 0; i < n.allImages.length; i++) n.allImages[i].type == "preview" && n.allImages[i].imageType == "normal" && e.push(n.allImages[i]);
            t = "click";
            h = n.resizeButton;
            h.bind(t, function() {
                event.preventDefault();
                f = 1;
                nt(f)
            });
            c = n.moveButton;
            c.bind(t, function() {
                event.preventDefault();
                f = 2;
                nt(f)
            });
            p = n.resetButton;
            p.bind(t, function() {
                event.preventDefault();
                g(r.find("img"), e[o])
            });
            w = n.clockwiseButton;
            w.bind(t, function() {
                event.preventDefault();
                st()
            });
            b = n.anticlockwiseButton;
            b.bind(t, function() {
                event.preventDefault();
                ht()
            });
            k = n.downloadButton;
            k.bind(t, function() {
                Ares.download(e[o].mediumSizeImageUrl)
            });
            r.bind("mousedown", function(n) {
                ft(n)
            });
            $("body").bind("mouseup", function(n) {
                ot(n)
            });
            $("body").bind("mousemove", function(n) {
                et(n)
            });
            rt()
        }

        function rt() {
            var n, i;
            for (y.append('<div id="thumblist" style="width:200px;margin:10px; overflow-y:scroll;"><\/div>'), v = y.find("#thumblist"), seriesIndex = 0, n = 0; n < e.length; n++) {
                var r = e[n],
                    u = "",
                    t = new Image;
                t.src = r.thumbnailUrl;
                t.complete ? u = t.width > t.height ? "width:170px;" : "height:170px;" : t.onload = function() {
                    t.onload = null
                };
                i = "margin:0px 10px;width:170px;height:170px;background-color:#fff;overflow:hidden;position:relative;display:table-cell;text-align:center;vertical-align:middle;";
                r.id == tt.id ? (i += " border:2px solid #46aaf6;", d(n)) : i += " border:2px solid #808080;";
                v.append('<div imgIndex="' + n + '" style="' + i + '"><img style="' + u + '" src="' + r.thumbnailUrl + '" /><\/div><br />')
            }
            v.children().bind("click", function() {
                ut($(this))
            })
        }

        function d(n) {
            var t = e[n];
            o = n;
            r.empty();
            $.ajax({
                type: "GET",
                url: "/ImageContent/FullImage?id=" + t.id,
                success: function(n) {
                    var u = $(n).find("img"),
                        i = new Image,
                        f;
                    r.append(i);
                    f = r.find("img");
                    i.src = u.attr("src");
                    g($(i), t)
                }
            })
        }

        function g(n, r) {
            var f, e, s, o;
            i = {};
            t = {};
            f = r.width;
            e = r.height;
            n.attr("draggable", !1);
            n.css("position", "absolute");
            u = 0;
            n.css("transform", "rotate(0deg)");
            f / e > width / height ? (s = width / f * e, n.css("height", s), n.css("width", f * (s / e)), n.css("left", "0"), n.css("top", (height - s) / 2), t.w = f * (s / e), t.h = s, i.x = t.w / 2, i.y = (height - s) / 2 + s / 2) : (o = height * f / e, n.css("width", o), n.css("height", e * (o / f)), n.css("top", "0"), n.css("left", (width - o) / 2), t.h = e * (o / f), t.w = o, i.x = (width - o) / 2 + o / 2, i.y = e * (o / f) / 2)
        }

        function ut(n) {
            var t = parseInt(n.attr("imgIndex"));
            o != t && (o = t, v.children().css("border-color", "#808080"), n.css("border-color", "#46aaf6"), d(o))
        }

        function ft(n) {
            var t = n.pageX,
                i = n.pageY;
            l = !0;
            a = t;
            s = i;
            return
        }

        function et(n) {
            var c = n.pageX,
                o = n.pageY,
                u, h, e;
            if (l && f == 1) {
                if (u = r.find("img"), h = o - s, a = c, s = o, e = 1 - h / 500, t.w * e > width * 2 || t.h * e > height * 2 || t.h * e < height / 2) return;
                t.w = t.w * e;
                t.h = t.h * e;
                u.css("width", t.w);
                u.css("height", t.h);
                u.css("left", i.x - t.w / 2);
                u.css("top", i.y - t.h / 2)
            } else if (l && f == 2) {
                var u = r.find("img"),
                    v = c - a,
                    h = o - s;
                a = c;
                s = o;
                i.x = i.x + v;
                i.y = i.y + h;
                u.css("left", i.x - t.w / 2);
                u.css("top", i.y - t.h / 2)
            }
        }

        function ot() {
            l = !1
        }

        function st() {
            var n = r.find("img");
            u = u + 90;
            n.css("transform", "rotate(" + u + "deg)")
        }

        function ht() {
            var n = r.find("img");
            u = u - 90;
            n.css("transform", "rotate(" + u + "deg)")
        }

        function nt(n) {
            h.children().attr("src", "/app-resource/images/dcm/resize.png");
            c.children().attr("src", "/app-resource/images/dcm/move.png");
            n == 1 ? h.children().attr("src", "/app-resource/images/dcm/resize_e.png") : n == 2 && c.children().attr("src", "/app-resource/images/dcm/move_e.png")
        }
        var r = n.viewer,
            y = n.leftBar;
        width = parseInt(n.width);
        height = parseInt(n.height);
        var f = -1,
            h, c, p, w, b, k, l = !1,
            a, s, i, t, u = 0,
            v, e = [],
            tt = n.image,
            o = -1;
        it(n)
    }
}(window)